<!doctype html>
<html>
<head>
    <meta charset="UTF-8">
    <title><{:C('web_site_name')}>---新闻类别的添加</title>
<link rel="stylesheet" type="text/css" href="<?php echo APP_TMPL_PATH ; ?>/static/css/common.css"/>
<link rel="stylesheet" type="text/css" href="<?php echo APP_TMPL_PATH ; ?>/static/css/main.css"/>
<script type="text/javascript" src="<?php echo APP_TMPL_PATH ; ?>/static/js/jquery.js"></script>
<script type="text/javascript" src="<?php echo APP_TMPL_PATH ; ?>/static/js/layer/lib.js"></script>
<script type="text/javascript" src="<?php echo APP_TMPL_PATH ; ?>/static/js/layer/layer.min.js"></script>
<script type="text/javascript" src="<?php echo APP_TMPL_PATH ; ?>/static/js/fileuploader.js"></script>
</head>
<body>


<form  id="info_form" >
<input type="hidden" value="<?php echo $info['id'] ;?>" name="info[id]">
<div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i>首页<span class="crumb-step">&gt;</span><span class="crumb-name">新闻咨询类别添加</span></div>
        </div>
        
        <div class="result-wrap">
            <div class="result-content">
                    <table class="insert-tab" width="100%">
                        <tbody>
                            <tr>
                                <th><i class="require-red">*</i>上级栏目：</th>
                                <td>
                                <select name="info[pid]" style="width:300px">
							<option value="0">顶层栏目</option>
							<?php 
								if(isset($category) && $category ){
				foreach($category as $k => $v ){
	
		?>
							<option value="<?php echo $v['id'];?>" <?php if($info['pid'] == $v['id']){echo "selected";}?>><?php echo $v['html'];?><?php echo $v['typename'];?></option>
							<?php }} ?>
							</select>
           
                                </td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>栏目名称：</th>
                                <td>
                                <input id="typename"  value="<?php echo $info['typename'] ;?>" name="info[typename]" type="text" class="common-text required" /><i class="">请输入类别名称</i>
           
                                </td>
                            </tr> 
                             <tr>
                                <th><i class="require-red">*</i>栏目图片：</th>
                                <td>
                                <input type="text" value="<?php echo $info['pic'] ;?>" name="info[pic]" id="pic" readonly><a id="upload_pic" href="javascript:void(0)" class="btn btn-primary btn2">上传图片</a>
           
                                </td>
                            </tr> 
                            <tr>
                                <th><i class="require-red">*</i>图片预览：</th>
                                <td>
                                <img src="" id="preview" style="display:none">
           
                                </td>
                            </tr>
                            <tr>
                                <th><i class="require-red">*</i>排序：</th>
                                <td>
                                <input id="disorder" name="info[disorder]" type="text" value="<?php echo $info['disorder'] ;?>"  class="common-text required" />
           
                                </td>
                            </tr>
                            <tr>
                                <th>SEO标题：</th>
                                <td>
                                <input id="typename" value="<?php echo $info['seotitle'] ;?>" name="info[seotitle]" id="seotitle" type="text" class="common-text required" /><i class="">请输入SEO标题</i>
           
                                </td>
                            </tr>
                            <tr>
                                <th>关键字：</th>
                                <td>
                                <input value="<?php echo $info['keywords'] ;?>" id="typename" name="info[keywords]" type="text" class="common-text required" /><i class="">请输入关键词</i>
           
                                </td>
                            </tr>
                            <tr>
                                <th>栏目描述：</th>
                                <td>
                                 <textarea  style="border:solid 1px #A7B5BC ;width:345px ; height:90px"  name="info[description]" class="dfinput"><?php echo $info['description'] ;?></textarea>
           
                                </td>
                            </tr>
                            <tr>
                                <th>状态：</th>
                                <td>
                                <input type="radio" name="info[status]" value="1" <?php if($info['status'] == 1 ){echo "checked";}?>/> 启用
   								 <input type="radio" name="info[status]" value="0" <?php if($info['status'] == 0 ){echo "checked";}?>/> 禁用
                                </td>
                            </tr>
                            <tr>
                                <th></th>
                                <td>
                                    <input class="btn btn-primary btn6 mr10" id="btn" value="提交" type="button">
                                </td>
                            </tr>
                        </tbody></table>
            </div>
        </div>
       
      </form>  
    
   </body>
   </html>    
   
<script>

var loadding_0 ;
$(function(){
	$("#btn").bind("click" , function(){
		if($.trim($("#typename").val()) == '' ){
			layer.msg("名称不可以为空");
			return false ;
		}
		var data_ = $("#info_form").serializeArray() ;
		$.ajax({
			type: "POST",
			url: "<?php echo  U("newstype/edit" , array('action'=>'doedit' , 'showpage'=>1 ) ) ; ?>" ,
			data: data_,
			cache:false,
			dataType:"json",
			async:true,
			success: function(msg){
				var shtml = '' ;
				if(msg.resultcode != 1 ){
					layer.msg(msg.resultinfo.errmsg);
					return false ;
				}else{
					parent.common_request();
					parent.close_edit_div();
				}
				layer.close(loadding_0);
				
			},
			beforeSend:function(){
				 loadding_0 = layer.load('数据正在加载中。。。。。。'); 
			},
			error:function(){
				layer.msg('服务器繁忙请稍后');
				return false ;
			}
			});
		
	});
	 var img_uploader = new qq.FileUploaderBasic({
	        allowedExtensions: ['jpg','gif','jpeg','png'],
	        button: document.getElementById("upload_pic"),
	        multiple: false,
	        action: "<?php echo U('newstype/index' , array('action'=>'upload_pic') )?>",
	        inputName: 'file',
	        forceMultipart: true, //用$_FILES
	        messages: {
	            typeError: "图片类型出错",
	            //sizeError: "七个上传小图",
	            //minSizeError: lang.upload_minsize_error,
	            //emptyError: lang.upload_empty_error,
	            noFilesError: "没有文件上传"
	            //onLeave: lang.upload_onLeave
	        },
	        showMessage: function(message){
	           alert(message);
	        },
	        onSubmit: function(id, fileName){
	        	loadding_0 = layer.load('图片正在上传中，请稍等。。。。'); 
	        },
	        onComplete: function(id, fileName, result){
	        	
				if(result['resultcode']){
					$("#pic").val(result['resultinfo']['list']['pic']);
					$("#preview").attr("src" , "<?php echo C('upload_domain')?>/Newstype/"+result['resultinfo']['list']['pic']).show();
				}else{
					layer.msg(result['message']);
				}
	            layer.close(loadding_0);
	        }
	    });		

}) ; 


</script>
        
        